package com.wondedDream.controller.web;

import com.wondedDream.model.MockExamQuestion;
import com.wondedDream.model.UserMockExamQuestionRecord;
import com.wondedDream.service.UserMockExamQuestionRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController(value = "webUserMockExamQuestionRecordController")
@RequestMapping("/web/userMockExamQuestionRecords")
@Api(description = "客户端-用户模考详情问题记录模块")
public class UserMockExamQuestionRecordController {
    @Autowired
    private UserMockExamQuestionRecordService userMockExamQuestionRecordService;

    // 考试结束提交时调用-保存用户模考问题记录
    @PostMapping("/")
    @ApiOperation(value = "保存用户模考问题记录")
    public UserMockExamQuestionRecord saveUserMockExamQuestionRecord(@RequestBody UserMockExamQuestionRecord record) {
        return userMockExamQuestionRecordService.saveUserMockExamQuestionRecord(record);
    }

    // 详情-根据openid，模考id 查询问题记录
    @GetMapping("/getUserMockExamQuestionRecordByIdAndOpenid")
    @ApiOperation(value = "根据记录 ID 获取用户模考问题记录")
    public List<MockExamQuestion> getUserMockExamQuestionRecordByIdAndOpenid(@RequestParam("userMockExamRecordId") Integer userMockExamRecordId,
                                                                @RequestParam("userOpenId") String userOpenId) {
        return userMockExamQuestionRecordService.getUserMockExamQuestionRecordByIdAndOpenid(userMockExamRecordId,userOpenId);
    }


    // 只看错题-根据openid，模考id 查询错题问题记录
    @GetMapping("/getUserErrorMockExamQuestionRecordByIdAndOpenid")
    @ApiOperation(value = "根据记录 ID 获取用户模考问题记录")
    public List<MockExamQuestion> getUserErrorMockExamQuestionRecordByIdAndOpenid(@RequestParam("userMockExamRecordId") Integer userMockExamRecordId,
                                                                             @RequestParam("userOpenId") String userOpenId) {
        return userMockExamQuestionRecordService.getUserErrorMockExamQuestionRecordByIdAndOpenid(userMockExamRecordId,userOpenId);
    }


}

